/**
 * 
 */
package com.pmsco.pms.services.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pmsco.pms.core.dao.MedicineCategoryDao;
import com.pmsco.pms.core.domain.Category;
import com.pmsco.pms.core.domain.Medicine;
import com.pmsco.pms.core.domain.MedicineCategory;
import com.pmsco.pms.services.interfaces.MedicineCategoryService;

/**
 * @author Long Tran
 *
 */
public class MedicineCategoryServiceImpl implements MedicineCategoryService {
	private static final Logger logger = LoggerFactory.getLogger(MedicineCategoryServiceImpl.class);

	private static MedicineCategoryDao medicineCategoryDao;
	
	public MedicineCategory getMedicineCategory(Long medicineId, Long categoryId) {
		logger.info("Start getMedicineCategory");
		logger.debug("Category id: " + categoryId);
		logger.debug("Medicine id: " + medicineId);
		Medicine medicine = new Medicine();
		medicine.setId(medicineId);
		Category category = new Category();
		category.setId(categoryId);
		MedicineCategory medicineCategory = new MedicineCategory();
		medicineCategory.setCategory(category);
		medicineCategory.setMedicine(medicine);
		logger.info("End getMedicineCategory");
		return medicineCategoryDao.loadMedicineCategory(medicineCategory);
	}

	/**
	 * @param medicineCategoryDao the medicineCategoryDao to set
	 */
	public void setMedicineCategoryDao(MedicineCategoryDao medicineCategoryDao) {
		logger.info("Start setMedicineCategoryDao");
		logger.debug("Medicine Category Dao: " + medicineCategoryDao);
		this.medicineCategoryDao = medicineCategoryDao;
		logger.info("End setMedicineCategoryDao");
	}

	public void saveOrUpdateMedicineCategory(MedicineCategory medicineCategory) {
		medicineCategoryDao.saveOrUpdateMedicineCategory(medicineCategory);
	}

}
